#pragma once
#include <vector>
#include "ring.h"

//---------------------------------------------------------------------------
class test_base
{
public:
	test_base(long loops, bool force_context_switch):_count_to(loops), _force_context_switch(force_context_switch){}
	virtual ~test_base(){}

	virtual DWORD go(int processors, int threads_per_processor, bool is_fair);
	virtual std::string test_name(void) = 0;

protected:
	static DWORD static_threads_func(void* instance);
	void threads_func();

	virtual void test_init() = 0;
	virtual void do_test() = 0;
	DWORD_PTR calc_thread_affinity(int threads_per_processor, int i);
	void set_process_affinity(int processors);

protected:
	std::vector<HANDLE>		_threads;
	std::unique_ptr<ring>	_ring = nullptr;
	volatile long			_loops;
	long					_count_to;
	bool					_is_fair;
	bool					_force_context_switch;
};
//---------------------------------------------------------------------------